<!-- 表单1列 -->
<template>
  <el-dialog :visible.sync="params.show" @open="init" :before-close="cancel" class="dialog-form" width="400px">
    <DialogFormTitle slot="title" title="表单1列" />
    <el-form :model="formData" ref="formData" label-position="top">
      <el-form-item label="输入框" prop="xxx1" :rules="[V.required]">
        <FInput width="100%" v-model.trim="formData.xxx1" />
      </el-form-item>
      <el-form-item label="文本域" prop="xxx5">
        <FTextarea width="100%" v-model.trim="formData.xxx5" />
      </el-form-item>
    </el-form>
    <span slot="footer">
      <el-button type="info" @click="cancel">{{$t('button.Cancel')}}</el-button>
      <el-button type="primary" @click="submit" :loading="loading">{{$t('button.OK')}}</el-button>
    </span>
  </el-dialog>
</template>

<script>
import mixinDialogForm from '@/mixin/dialog-form'
import { DISABLE } from '@/constants/basic-data'

export default {
  mixins: [mixinDialogForm],
  props: {
    params: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      DISABLE,
      loading: false,
      formData: {}
    }
  },
  methods: {
    /**
     * 弹框初始化
     */
    init() {
      this.formData = {}
      if (this.params.data) {
        this.formData = this.params.data
      }
      this.$refs['formData'] && this.$refs['formData'].resetFields()
    },
    /**
     * 提交
     */
    submit() {
      this.$refs.formData.validate((valid) => {
        if (valid) {
          this.loading = true
          this.loading = false
        }
      })
    }
  }
}
</script>
